exports.database_name = 'faceoz';
exports.screen_width = Titanium.Platform.displayCaps.platformWidth;
exports.screen_height = Titanium.Platform.displayCaps.platformHeight;
exports.default_table_view_row_height = 45;
exports.font_color = '#000';
exports.font_size = 18;
exports.font_weight = 'bold';
exports.font_family = 'Helvetica Neue';
exports.normal_font_size = 16;
exports.middle_font_size = 14;
exports.small_font_size = 12;
exports.hint_text_font_color = '#333';
exports.hint_text_font_opacity = 0.3;
exports.selected_value_font_color = '#336699';
exports.default_time_out = 60000;
exports.modal_message_window = null;
exports.sub_modal_message_window = null;
exports.progress_bar = null;
exports.actInd = null;
//60 seconds
exports.process_simple_error_message = function(error, function_name) {
	alert(JSON.stringify(error) + ' --' + function_name);
};

exports.replace = function(origin_str, query_str, replace_str) {
	if ((origin_str === undefined) || (origin_str === null) || (origin_str === '')) {
		return '';
	}
	origin_str = origin_str.toString();
	return origin_str.replace(new RegExp(query_str.toString(), "g"), replace_str.toString());
};
exports.is_iphone_os = function() {
	return (Titanium.Platform.name == 'iPhone OS') ? true : false;
};
exports.display_indicator = function(message, has_progress_bar) {
	var self = this;
	function _create_model_message_window(message, has_progress_bar) {
		try {
			if (self.is_iphone_os()) {
				//for iphone and ipad
				self.modal_message_window = Ti.UI.createWindow({
					backgroundColor : '#999',
					fullscreen : false,
					opacity : 0.8
				});
				self.sub_modal_message_window = Titanium.UI.createView({
					backgroundColor : '#113D69',
					borderWidth : 4,
					borderColor : '#999',
					height : 120,
					width : 280,
					borderRadius : 8
				});
				self.modal_message_window.add(self.sub_modal_message_window);
				if (has_progress_bar) {
					self.actInd = Ti.UI.createActivityIndicator({
						font : {
							fontSize : self.font_size,
							fontWeight : self.font_weight
						},
						color : '#fff',
						message : message,
						width : 'auto',
						height : 'auto'
					});
					self.sub_modal_message_window.add(self.actInd);
					self.actInd.show();
					self.progress_bar = Titanium.UI.createProgressBar({
						width : 200,
						min : 0,
						max : 1,
						value : 0,
						height : 50,
						color : '#888',
						style : Titanium.UI.iPhone.ProgressBarStyle.PLAIN,
						font : {
							fontSize : 14,
							fontWeight : 'bold'
						},
						bottom : 15
					});
					self.sub_modal_message_window.add(self.progress_bar);
					self.progress_bar.show();
				} else {
					self.actInd = Ti.UI.createActivityIndicator({
						font : {
							fontSize : self.font_size,
							fontWeight : self.font_weight
						},
						color : '#fff',
						message : message,
						width : 'auto',
						height : 'auto'
					});
					self.sub_modal_message_window.add(self.actInd);
					self.actInd.show();
				}
			} else {
				self.actInd = Ti.UI.createActivityIndicator({
					font : {
						fontSize : self.font_size,
						fontWeight : self.font_weight
					},
					color : '#fff',
					message : message,
					width : 'auto',
					height : 'auto'
				});
				self.actInd.show();
			}
		} catch(err) {
			self.process_simple_error_message(err, "_create_model_message_window");
			return;
		}
	}

	try {
		if ((has_progress_bar === null) || (has_progress_bar === undefined)) {
			has_progress_bar = false;
		}
		_create_model_message_window(message, has_progress_bar);
		if (self.is_iphone_os()) {
			self.modal_message_window.open({
				modal : false
			});
		}
	} catch(err) {
		self.process_simple_error_message(err, "display_indicator");
		return;
	}
};
exports.hide_indicator = function() {
	var self = this;
	try {
		if (self.is_iphone_os()) {
			if (self.modal_message_window != null) {
				self.modal_message_window.close();
				self.modal_message_window = null;
				self.sub_modal_message_window = null;
				if (self.progress_bar != null) {
					self.progress_bar = null;
				}
				if (self.actInd != null) {
					self.actInd = null;
				}
			}
		} else {
			if (self.actInd != null) {
				self.actInd.hide();
				self.actInd = null;
			}
		}
	} catch(err) {
		self.process_simple_error_message(err, "hide_indicator");
		return;
	}
}; 